Kanzi  3.9.9
Kanzi Engine C++ API
kanzi::ColorRGBA Class Reference

Color with 4 floating point components: red, green, blue and alpha (r, g, b, a). More...

#include <kanzi/core/math/color_rgba.hpp>

Public Member Functions

 ColorRGBA ()
 Default constructor, initializes the color to (0.0, 0.0, 0.0, 0.0). More...
 
 ColorRGBA (float v)
 Constructor, initializes the color to (v, v, v, v). More...
 
 ColorRGBA (float r, float g, float b)
 Constructor, initializes the color to (r, g, b, 1.0). More...
 
 ColorRGBA (float r, float g, float b, float a)
 Constructor, initializes the color to (r, g, b, a). More...
 
float getAlpha () const
 Returns the alpha element of the color. More...
 
float getBlue () const
 Returns the blue element of the color. More...
 
float getGreen () const
 Returns the green element of the color. More...
 
float getRed () const
 Returns the red element of the color. More...
 
bool hasNan () const
 Returns true if and only if at least one of the vector values is NaN. More...
 
ColorRGBAoperator*= (float scalar)
 Multiplies each color element with a scalar. More...
 
ColorRGBAoperator+= (float scalar)
 Adds a scalar to each color element. More...
 
ColorRGBAoperator+= (const ColorRGBA &v)
 Modifies this color by adding another color. More...
 
ColorRGBAoperator-= (const ColorRGBA &v)
 Modifies this color by subtracting another color from this color. More...
 
ColorRGBAoperator/= (float scalar)
 Divides each color element with a scalar. More...
 
const float & operator[] (size_t index) const
 Access to individual elements of the color. More...
 
float & operator[] (size_t index)
 Access to individual elements of the color. More...
 
void setAlpha (float value)
 Sets the alpha element of the color. More...
 
void setBlue (float value)
 Sets the blue element of the color. More...
 
void setGreen (float value)
 Sets the green element of the color. More...
 
void setRed (float value)
 Sets the red element of the color. More...
 

Static Public Member Functions

static KZ_NO_DISCARD ColorRGBA fromSRGB (float r, float g, float b, float a)
 Returns a linear color with each element set from a sRGB value. More...
 
static KZ_NO_DISCARD ColorRGBA fromSRGB (float r, float g, float b)
 Returns a linear color with each element set from a sRGB value. More...
 
static ColorRGBA highestValue ()
 Returns the color with each element having the most positive float value. More...
 
static ColorRGBA lowestValue ()
 Returns the color with each element having the most negative float value. More...
 
static ColorRGBA nan ()
 Returns the color with each element being NaN. More...
 
static ColorRGBA negativeInfinity ()
 Returns the color with each element being the negative infinity. More...
 
static KZ_NO_DISCARD const ColorRGBA one ()
 Returns the color with each element being one. More...
 
static ColorRGBA opaqueBlack ()
 Returns opaque black color (0.0, 0.0, 0.0, 1.0). More...
 
static ColorRGBA positiveInfinity ()
 Returns the color with each element being the positive infinity. More...
 
static ColorRGBA transparentBlack ()
 Returns transparent black color (0.0, 0.0, 0.0, 0.0). More...
 
static KZ_NO_DISCARD const ColorRGBA zero ()
 Returns the color with each element being zero. More...
 

Detailed Description

Color with 4 floating point components: red, green, blue and alpha (r, g, b, a).

Constructor & Destructor Documentation

kanzi::ColorRGBA::ColorRGBA ( )
inlineexplicit

Default constructor, initializes the color to (0.0, 0.0, 0.0, 0.0).

kanzi::ColorRGBA::ColorRGBA ( float  v)
inlineexplicit

Constructor, initializes the color to (v, v, v, v).

Parameters
vRed, Green, Blue, and Alpha component of the color.
kanzi::ColorRGBA::ColorRGBA ( float  r,
float  g,
float  b 
)
inlineexplicit

Constructor, initializes the color to (r, g, b, 1.0).

Parameters
rRed component of the color.
gGreen component of the color.
bBlue component of the color.
kanzi::ColorRGBA::ColorRGBA ( float  r,
float  g,
float  b,
float  a 
)
inlineexplicit

Constructor, initializes the color to (r, g, b, a).

Parameters
rRed component of the color.
gGreen component of the color.
bBlue component of the color.
aAlpha component of the color.

Member Function Documentation

const float& kanzi::ColorRGBA::operator[] ( size_t  index) const
inline

Access to individual elements of the color.

Parameters
indexIndex of the accessed element. Should be either 0, 1, 2, or 3.
Returns
If index is 0, r element. If index is 1, g element. If index is 2, b element. If index is 3, a element.
float& kanzi::ColorRGBA::operator[] ( size_t  index)
inline

Access to individual elements of the color.

Parameters
indexIndex of the accessed element. Should be either 0, 1, 2, or 3.
Returns
If index is 0, r element. If index is 1, g element. If index is 2, b element. If index is 3, a element.
ColorRGBA& kanzi::ColorRGBA::operator*= ( float  scalar)
inline

Multiplies each color element with a scalar.

Parameters
scalarMultiplier for each color element.
Returns
This color.
ColorRGBA& kanzi::ColorRGBA::operator/= ( float  scalar)
inline

Divides each color element with a scalar.

Parameters
scalarDivider for each color element.
Returns
This color.
ColorRGBA& kanzi::ColorRGBA::operator+= ( float  scalar)
inline

Adds a scalar to each color element.

Parameters
scalarAnother color.
Returns
This color.
ColorRGBA& kanzi::ColorRGBA::operator+= ( const ColorRGBA v)
inline

Modifies this color by adding another color.

Parameters
vAnother color.
Returns
This color.
ColorRGBA& kanzi::ColorRGBA::operator-= ( const ColorRGBA v)
inline

Modifies this color by subtracting another color from this color.

Parameters
vAnother color.
Returns
This color.
static KZ_NO_DISCARD const ColorRGBA kanzi::ColorRGBA::zero ( )
inlinestatic

Returns the color with each element being zero.

Returns
Color with zeroed elements.
static KZ_NO_DISCARD const ColorRGBA kanzi::ColorRGBA::one ( )
inlinestatic

Returns the color with each element being one.

Returns
Color with unit element values.
static KZ_NO_DISCARD ColorRGBA kanzi::ColorRGBA::fromSRGB ( float  r,
float  g,
float  b,
float  a 
)
inlinestatic

Returns a linear color with each element set from a sRGB value.

Parameters
rRed Channel (0-1.0)
gGreen Channel (0-1.0)
bBlue Channel (0-1.0)
aAlpha Channel (0-1.0)
Returns
Color in linear color space.
static KZ_NO_DISCARD ColorRGBA kanzi::ColorRGBA::fromSRGB ( float  r,
float  g,
float  b 
)
inlinestatic

Returns a linear color with each element set from a sRGB value.

Parameters
rRed Channel (0-1.0)
gGreen Channel (0-1.0)
bBlue Channel (0-1.0)
Returns
Color in linear color space.
float kanzi::ColorRGBA::getRed ( ) const
inline

Returns the red element of the color.

Returns
The red element.
float kanzi::ColorRGBA::getGreen ( ) const
inline

Returns the green element of the color.

Returns
The green element.
float kanzi::ColorRGBA::getBlue ( ) const
inline

Returns the blue element of the color.

Returns
The blue element.
float kanzi::ColorRGBA::getAlpha ( ) const
inline

Returns the alpha element of the color.

Returns
The alpha element.
void kanzi::ColorRGBA::setRed ( float  value)
inline

Sets the red element of the color.

Parameters
valueThe new value of the red element.
void kanzi::ColorRGBA::setGreen ( float  value)
inline

Sets the green element of the color.

Parameters
valueThe new value of the green element.
void kanzi::ColorRGBA::setBlue ( float  value)
inline

Sets the blue element of the color.

Parameters
valueThe new value of the blue element.
void kanzi::ColorRGBA::setAlpha ( float  value)
inline

Sets the alpha element of the color.

Parameters
valueThe new value of the alpha element.
ColorRGBA kanzi::ColorRGBA::lowestValue ( )
inlinestatic

Returns the color with each element having the most negative float value.

Returns
Color with the lowest possible value.
ColorRGBA kanzi::ColorRGBA::highestValue ( )
inlinestatic

Returns the color with each element having the most positive float value.

Returns
Color with the highest possible value.
ColorRGBA kanzi::ColorRGBA::nan ( )
inlinestatic

Returns the color with each element being NaN.

Returns
Color with NaN elements.
bool kanzi::ColorRGBA::hasNan ( ) const
inline

Returns true if and only if at least one of the vector values is NaN.

ColorRGBA kanzi::ColorRGBA::positiveInfinity ( )
inlinestatic

Returns the color with each element being the positive infinity.

Returns
Color with positive infinity elements.
ColorRGBA kanzi::ColorRGBA::negativeInfinity ( )
inlinestatic

Returns the color with each element being the negative infinity.

Returns
Color with negative infinity elements.
ColorRGBA kanzi::ColorRGBA::opaqueBlack ( )
inlinestatic

Returns opaque black color (0.0, 0.0, 0.0, 1.0).

Returns
Opaque black.
ColorRGBA kanzi::ColorRGBA::transparentBlack ( )
inlinestatic

Returns transparent black color (0.0, 0.0, 0.0, 0.0).

Returns
Transparent black color.

The documentation for this class was generated from the following file: